/*
 * 文 件 名:  AlertDialogUtil.java
 * 版    权:  Huawei Technologies Co., Led. Copyright YYYY-YYYY,  All rights reserved
 * 描    述:  <描述>
 * 修 改 人:  cKF46827
 * 修改时间:  2011-5-25
 * 跟踪单号:  <跟踪单号>
 * 修改单号:  <修改单号>
 * 修改内容:  <修改内容>
 */

package com.bocai.dahuatech.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.bocai.dahuatech.R;

/**
 * 对话框工具类
 * 
 * @author cKF46827/蔡育铭
 * @version [1.0, 2011-5-25]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */

public final class DialogUtil {
    static AlertDialog twoDialog;
    private DialogUtil() {

    }


    /**
     *两个按钮
     * @param context
     * @param content
     * @param dismissContent
     * @param trueContent
     * @param onclickListener
     */

    public static void dialogForTwoButtonfinish(final Context context,int content,
                                          int dismissContent, int trueContent, View.OnClickListener onclickListener,View.OnClickListener onclickListenerdismiss) {
        View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_delete, null);
        twoDialog = new AlertDialog.Builder(context)
                .setView(dialogView).show();
        twoDialog.setCancelable(false);
        TextView tiitle = (TextView) twoDialog.findViewById(R.id.tv_dialog_title);
        TextView tvLogin = (TextView) twoDialog.findViewById(R.id.tv_dialog_delete);
        TextView dismiss = (TextView) twoDialog.findViewById(R.id.tv_dialog_dismiss);
        tvLogin.setText(trueContent);
        dismiss.setText(dismissContent);
        tiitle.setText(content);
        tvLogin.setOnClickListener(onclickListener);
        dismiss.setOnClickListener(onclickListenerdismiss);

    }

    /**
     *两个按钮
     * @param context
     * @param content
     * @param dismissContent
     * @param trueContent
     * @param onclickListener
     */

    public static void dialogForTwoButton(Context context,int content,
                                          int dismissContent, int trueContent, View.OnClickListener onclickListener) {
        View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_delete, null);
        twoDialog = new AlertDialog.Builder(context)
                .setView(dialogView).show();
        TextView tiitle = (TextView) twoDialog.findViewById(R.id.tv_dialog_title);
        TextView tvLogin = (TextView) twoDialog.findViewById(R.id.tv_dialog_delete);
        TextView dismiss = (TextView) twoDialog.findViewById(R.id.tv_dialog_dismiss);
        tvLogin.setText(trueContent);
        dismiss.setText(dismissContent);
        tiitle.setText(content);
        tvLogin.setOnClickListener(onclickListener);
        dismiss.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                twoDialog.cancel();
            }
        });
    }

    public static void dismissTowDialog(){
        if(twoDialog!=null){
            twoDialog.cancel();
        }
    }
//

    /**
     * 一个按钮
     * @param context
     * @param content
     * @param dismissContent
     */
public static void dialogForOneButton(Context context,int content, int dismissContent) {
    View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_know, null);
    final AlertDialog dialog = new AlertDialog.Builder(context)
            .setView(dialogView).show();
    TextView tiitle = (TextView) dialog.findViewById(R.id.tv_dialog_title);
    TextView dismiss = (TextView) dialog.findViewById(R.id.tv_dialog_dismiss);
    dismiss.setText(dismissContent);
    tiitle.setText(content);
    dismiss.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.cancel();
        }
    });
}

    /**
     * 一个按钮
     * @param context
     * @param content
     * @param dismissContent
     */
    public static void dialogForOneButton(Context context,String  content, int dismissContent) {
        View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_know, null);
        final AlertDialog dialog = new AlertDialog.Builder(context)
                .setView(dialogView).show();
        TextView tiitle = (TextView) dialog.findViewById(R.id.tv_dialog_title);
        TextView dismiss = (TextView) dialog.findViewById(R.id.tv_dialog_dismiss);
        dismiss.setText(dismissContent);
        tiitle.setText(content);
        dismiss.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }
        });
    }

}
